<?php


namespace app\common\model;


class SingleOrder extends BaseModel{

    protected $name = "single_order";

    public static function updateData($where,$data){
        //分销商表
        $flag = self::where($where)->find();
        if(!$flag){
            $single_data = [
                'amount'=>$data['amount'],
                'wxapp_id'=>$data['wxapp_id'],
                'pay_type'=>$data['pay_type'],
                'user_id'=>$data['user_id'],
                'create_time'=>time(),
                'update_time'=>time(),
            ];
            self::insert($single_data);
        }else{
            if($flag['amount']<$data['amount']){
                $data['update_time'] = time();
                self::where($where)->update($data);
            }
        }
    }

    /**
     * 获取指定用户单笔消费金额
     * @param $giftsId
     * @return static
     */

    public static function detail($where, $with = []){

        return static::get($where, $with);
    }

}